import { formatFieldValue } from '@/views/project/utils/formatters.js';

export const projectTranferDescriptionFileds = (response) => {
  // 项目接收信息动态数据
  const projectAcceptDesc = reactive([
    {
      label: '建设单位部门经理',
      type: 'userSelect',
      filed: 'construction_department_manager',
      content: response.construction_department_manager
    },
    // {
    //   label: '交底人审核意见',
    //   type: 'input',
    //   filed: 'accepter_reason',
    //   content: response.accepter_reason
    // }
  ])
  // 项目接收信息表单对象
  const projectAcceptForm = reactive({
    // accepter_reason: ''
  })
  // 选择交付经理
  const projectManagerDesc = reactive([
    {
      label: '交付经理',
      type: 'userSelect',
      filed: 'construction_project_manager',
      content: response.construction_project_manager
    }
  ])
  // 选择交付经理对象
  const projectManagerForm = reactive({
    construction_project_manager: ''
  })

  // 选择服务经理
  const maintenanceManagerDesc = reactive([
    {
      label: '服务经理',
      type: 'userSelect',
      filed: 'maintenance_manager',
      content: response.maintenance_manager
    }
  ])

  // 选择服务经理对象
  const maintenanceManagerForm = reactive({
    maintenance_manager: ''
  })

  // 项目流程-description组件动态数据
  const projectProcessDescs = reactive([
    {
      label: '项目流程类型',
      type: 'select',
      options: [
        {
          value: 'ICT成本（建设+运维模式）',
          label: 'ICT成本（建设+运维模式）'
        },
        {
          value: 'ICT成本（纯建设模式）',
          label: 'ICT成本（纯建设模式）'
        },
        {
          value: 'ICT成本（纯运维模式）',
          label: 'ICT成本（纯运维模式）'
        }
      ],
      filed: 'project_process_type',
      content: response.project_process_type
    },
    {
      label: '管理方式',
      type: 'select',
      options: [
        {
          value: '集团公司',
          label: '集团公司'
        },
        {
          value: '省公司',
          label: '省公司'
        },
        {
          value: '分公司',
          label: '分公司'
        }
      ],
      filed: 'management_mode',
      content: response.management_mode
    },
    {
      label: '投资主体',
      type: 'radioGroup',
      options: [
        {
          value: '上市公司',
          label: '上市公司'
        },
        {
          value: '非上市公司',
          label: '非上市公司'
        }
      ],
      filed: 'investment_type',
      content: response.investment_type
    },
    {
      label: '要求完成时间',
      type: 'datePicker',
      filed: 'required_finish_time',
      content: response.required_finish_time
    },
    {
      label: '业务类型',
      type: 'select',
      options: [
        {
          value: '纯软',
          label: '纯软'
        },
        {
          value: '纯硬',
          label: '纯硬'
        },
        {
          value: '软硬结合',
          label: '软硬结合'
        },
        {
          value: '服务',
          label: '服务'
        }
      ],
      filed: 'business_type',
      content: response.business_type
    },
    {
      label: '立项除税金额（元）',
      type: 'input',
      filed: 'init_cost_no_tax',
      content: response.init_cost_no_tax,
      validator: 'number'
    },
    {
      label: '是否含购销',
      type: 'radioGroup',
      options: [
        {
          value: 'true',
          label: '是'
        },
        {
          value: 'false',
          label: '否'
        }
      ],
      filed: 'purchase_and_sale',
      content: formatFieldValue('purchase_and_sale', response.purchase_and_sale)
    }
  ])
  // 项目流程-form表单对象数据
  const projectProcessForm = reactive({
    project_process_type: '',
    management_mode: '',
    investment_type: '',
    required_finish_time: '',
    // projectType: '',
    business_type: '',
    init_cost_no_tax: response.amount_no_tax,
    purchase_and_sale: 'true'
  })

  for (const key in projectProcessForm) {
    // 只更新未设置默认值的字段
    if (response.hasOwnProperty(key) && projectProcessForm[key] === '') {
      projectProcessForm[key] = response[key] || ''; // 如果 response 中没有该字段，保持为空字符串
    }
  }

  return {
    // 项目接收
    projectAcceptDesc,
    projectAcceptForm,
    // 选择交付经理
    projectManagerDesc,
    projectManagerForm,
    // 选择服务经理
    maintenanceManagerDesc,
    maintenanceManagerForm,
    // 项目流程信息
    projectProcessDescs,
    projectProcessForm,
  }
}